/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package ormsamples;

import org.orm.*;
public class ListTaller1PDSData {
	private static final int ROW_COUNT = 100;
	
	public void listTestData() throws PersistentException {
		System.out.println("Listing Pacient...");
		orm.Pacient[] ormPacients = orm.PacientDAO.listPacientByQuery(null, null);
		int length = Math.min(ormPacients.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormPacients[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing User...");
		orm.User[] ormUsers = orm.UserDAO.listUserByQuery(null, null);
		length = Math.min(ormUsers.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormUsers[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Doctor...");
		orm.Doctor[] ormDoctors = orm.DoctorDAO.listDoctorByQuery(null, null);
		length = Math.min(ormDoctors.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormDoctors[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing BabyMonitor...");
		orm.BabyMonitor[] ormBabyMonitors = orm.BabyMonitorDAO.listBabyMonitorByQuery(null, null);
		length = Math.min(ormBabyMonitors.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormBabyMonitors[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Solution...");
		orm.Solution[] ormSolutions = orm.SolutionDAO.listSolutionByQuery(null, null);
		length = Math.min(ormSolutions.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormSolutions[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Diagnose...");
		orm.Diagnose[] ormDiagnoses = orm.DiagnoseDAO.listDiagnoseByQuery(null, null);
		length = Math.min(ormDiagnoses.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormDiagnoses[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Response...");
		orm.Response[] ormResponses = orm.ResponseDAO.listResponseByQuery(null, null);
		length = Math.min(ormResponses.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormResponses[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Question...");
		orm.Question[] ormQuestions = orm.QuestionDAO.listQuestionByQuery(null, null);
		length = Math.min(ormQuestions.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormQuestions[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing QuestForm...");
		orm.QuestForm[] ormQuestForms = orm.QuestFormDAO.listQuestFormByQuery(null, null);
		length = Math.min(ormQuestForms.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormQuestForms[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
	}
	
	public void listByCriteria() throws PersistentException  {
		System.out.println("Listing Pacient by Criteria...");
		orm.PacientCriteria pacientCriteria = new orm.PacientCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//pacientCriteria.idPaciente.eq();
		pacientCriteria.setMaxResults(ROW_COUNT);
		orm.Pacient[] ormPacients = pacientCriteria.listPacient();
		int length =ormPacients== null ? 0 : Math.min(ormPacients.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormPacients[i]);
		}
		System.out.println(length + " Pacient record(s) retrieved."); 
		
		System.out.println("Listing User by Criteria...");
		orm.UserCriteria userCriteria = new orm.UserCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//userCriteria.codUser.eq();
		userCriteria.setMaxResults(ROW_COUNT);
		orm.User[] ormUsers = userCriteria.listUser();
		length =ormUsers== null ? 0 : Math.min(ormUsers.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormUsers[i]);
		}
		System.out.println(length + " User record(s) retrieved."); 
		
		System.out.println("Listing Doctor by Criteria...");
		orm.DoctorCriteria doctorCriteria = new orm.DoctorCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//doctorCriteria.idDoctor.eq();
		doctorCriteria.setMaxResults(ROW_COUNT);
		orm.Doctor[] ormDoctors = doctorCriteria.listDoctor();
		length =ormDoctors== null ? 0 : Math.min(ormDoctors.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormDoctors[i]);
		}
		System.out.println(length + " Doctor record(s) retrieved."); 
		
		System.out.println("Listing BabyMonitor by Criteria...");
		orm.BabyMonitorCriteria babyMonitorCriteria = new orm.BabyMonitorCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//babyMonitorCriteria.codSystem.eq();
		babyMonitorCriteria.setMaxResults(ROW_COUNT);
		orm.BabyMonitor[] ormBabyMonitors = babyMonitorCriteria.listBabyMonitor();
		length =ormBabyMonitors== null ? 0 : Math.min(ormBabyMonitors.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormBabyMonitors[i]);
		}
		System.out.println(length + " BabyMonitor record(s) retrieved."); 
		
		System.out.println("Listing Solution by Criteria...");
		orm.SolutionCriteria solutionCriteria = new orm.SolutionCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//solutionCriteria.idSolution.eq();
		solutionCriteria.setMaxResults(ROW_COUNT);
		orm.Solution[] ormSolutions = solutionCriteria.listSolution();
		length =ormSolutions== null ? 0 : Math.min(ormSolutions.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormSolutions[i]);
		}
		System.out.println(length + " Solution record(s) retrieved."); 
		
		System.out.println("Listing Diagnose by Criteria...");
		orm.DiagnoseCriteria diagnoseCriteria = new orm.DiagnoseCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//diagnoseCriteria.idDiag.eq();
		diagnoseCriteria.setMaxResults(ROW_COUNT);
		orm.Diagnose[] ormDiagnoses = diagnoseCriteria.listDiagnose();
		length =ormDiagnoses== null ? 0 : Math.min(ormDiagnoses.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormDiagnoses[i]);
		}
		System.out.println(length + " Diagnose record(s) retrieved."); 
		
		System.out.println("Listing Response by Criteria...");
		orm.ResponseCriteria responseCriteria = new orm.ResponseCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//responseCriteria.idResponse.eq();
		responseCriteria.setMaxResults(ROW_COUNT);
		orm.Response[] ormResponses = responseCriteria.listResponse();
		length =ormResponses== null ? 0 : Math.min(ormResponses.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormResponses[i]);
		}
		System.out.println(length + " Response record(s) retrieved."); 
		
		System.out.println("Listing Question by Criteria...");
		orm.QuestionCriteria questionCriteria = new orm.QuestionCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//questionCriteria.idQuest.eq();
		questionCriteria.setMaxResults(ROW_COUNT);
		orm.Question[] ormQuestions = questionCriteria.listQuestion();
		length =ormQuestions== null ? 0 : Math.min(ormQuestions.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormQuestions[i]);
		}
		System.out.println(length + " Question record(s) retrieved."); 
		
		System.out.println("Listing QuestForm by Criteria...");
		orm.QuestFormCriteria questFormCriteria = new orm.QuestFormCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//questFormCriteria.idQuestForm.eq();
		questFormCriteria.setMaxResults(ROW_COUNT);
		orm.QuestForm[] ormQuestForms = questFormCriteria.listQuestForm();
		length =ormQuestForms== null ? 0 : Math.min(ormQuestForms.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormQuestForms[i]);
		}
		System.out.println(length + " QuestForm record(s) retrieved."); 
		
	}
	
	public static void main(String[] args) {
		try {
			ListTaller1PDSData listTaller1PDSData = new ListTaller1PDSData();
			try {
				listTaller1PDSData.listTestData();
				//listTaller1PDSData.listByCriteria();
			}
			finally {
				orm.Taller1PDSPersistentManager.instance().disposePersistentManager();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
